package define.Demo_02.Car;

import java.util.Scanner;

public class CarsTest {
    public static void main(String[] args) {
        //创建数组
        Cars[] cars = new Cars[3];
        //创建对象
        Cars car1 = new Cars();
        Cars car2 = new Cars();
        Cars car3 = new Cars();
        //将对象放入数组
        cars[0] = car1;
        cars[1] = car2;
        cars[2] = car3;
        //输入信息
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < cars.length; i++) {
            Cars car = cars[i];
            System.out.println("请输入第" + (i + 1) + "辆车的信息：");
            System.out.print("请输入车的id：");
            String id = scanner.next();
            car.setId(id);
            System.out.print("请输入车的品牌：");
            String brand = scanner.next();
            car.setBrand(brand);
            System.out.print("请输入车的价格：");
            double price = scanner.nextDouble();
            car.setPrice(price);
            System.out.print("请输入车的颜色：");
            String color = scanner.next();
            car.setColor(color);


        }

    }
}
